/*
 * user_define.h
 *
 *  Created on: 2023��4��11��
 *      Author: Tim
 */

#ifndef USER_DEFINE_H_
#define USER_DEFINE_H_


#include <stdint.h>
#include <stdbool.h>

#define CAN_USED          (TRUE)
#define LIN_USED          (TRUE)
#define UART_USED         (TRUE)
#define CAPTURE_USED      (TRUE)
#define PWM_OUT_USED      (TRUE)
#define ADC_USED          (FALSE)
#define CDD_USED          (TRUE)
#define LPTMR_USED        (TRUE)
#define LPIT_USED         (FALSE)

#define ON                  (TRUE)
#define OFF                 (FALSE)

#ifndef TRUE
#define	TRUE (1u)
#endif

#ifndef FALSE
#define	FALSE (!TRUE)
#endif

#ifndef NULL_PTR
#define NULL_PTR ((void *)0u)
#endif

#define BIT_0	                    ( 1 << 0x0 )
#define BIT_1	                    ( 1 << 0x1 )
#define BIT_2	                    ( 1 << 0x2 )
#define BIT_3	                    ( 1 << 0x3 )
#define BIT_4	                    ( 1 << 0x4 )
#define BIT_5	                    ( 1 << 0x5 )
#define BIT_6	                    ( 1 << 0x6 )
#define BIT_7	                    ( 1 << 0x7 )
#define BIT_8	                    ( 1 << 0x8 )
#define BIT_9	                    ( 1 << 0x9 )
#define BIT_10	                    ( 1 << 0xA )
#define BIT_11	                    ( 1 << 0xB )
#define BIT_12	                    ( 1 << 0xC )
#define BIT_13	                    ( 1 << 0xD )
#define BIT_14	                    ( 1 << 0xE )
#define BIT_15	                    ( 1 << 0xF )
#define BIT_16	                    ( 1 << 0x10 )
#define BIT_17	                    ( 1 << 0x11 )
#define BIT_18	                    ( 1 << 0x12 )
#define BIT_19	                    ( 1 << 0x13 )
#define BIT_20	                    ( 1 << 0x14 )
#define BIT_21	                    ( 1 << 0x15 )
#define BIT_22	                    ( 1 << 0x16 )
#define BIT_23	                    ( 1 << 0x17 )

#define EVENRGROUP_TL               BIT_0
#define EVENRGROUP_TR               BIT_1
#define EVENRGROUP_PL               BIT_2
#define EVENRGROUP_PR               BIT_3
#define EVENRGROUP_SWIPE            BIT_4
#define EVENRGROUP_LIGHT_SHOW       BIT_5
#define EVENRGROUP_LIGHT_NORMAL     BIT_14


#ifndef PARA_ASSERT_RTN
#define PARA_ASSERT_RTN(x,y)   {if(x) return y;}
#endif

#define GRILLE_PORT                 PTC
#define GRILLE_PIN                  8

#define L_REFLECT_PORT1               PTE
#define L_REFLECT_PORT23              PTB
#define L_REFLECT_PIN_LED1            8
#define L_REFLECT_PIN_LED2            5  
#define L_REFLECT_PIN_LED3            4  
#define R_REFLECT_PORT                PTA
#define R_REFLECT_PIN_LED4            12
#define R_REFLECT_PIN_LED6            10  

#define BRAKE_STOP_PORT               PTA
#define BRAKE_STOP_PIN                11

/* BUFFER config */
#define TX_MAILBOX                  (2UL)
#define RX_MAILBOX                  (3UL)
#define EOL_TX_MAILBOX              (4UL)
#define EOL_RX_MAILBOX              (5UL)
#define exTX_MAILBOX                (6UL)/*ר������������չ֡*/
/*-----------------------------------------------------------*/
/* TX CAN ID define */
#define DOMAIN_BEHIND               (0x567)

/* RX CAN ID define */
#define GATE_SUB_1                  (0x210)
#define HTCU_VCU_1                  (0x220)
#define MUSICLOUD_1                 (0x230)
#define SENSOR_1                    (0x601)
/*-----------------------------------------------------------*/
#define CLOSE                               0x0     //关闭
#define ACTIVE                              0x1     //开启

#define P_GEAR                              0x1     //P档
#define R_GEAR                              0x2     //R档
#define N_GEAR                              0x3     //N档
#define D_GEAR                              0x4     //D档

#define BATTERY_LOW                         0x1     //电量小于20

#define DISTANCE_CLOSE                      0xd     //距离小于3m

#define ANGLE720                            0xAD00   //左转720度
#define ANGLE_720                           0xffffffffffff5300  //右转720度
#define PARK_SPEED                          0x140    //车速20km/h
#define SAFETY_DISTANCE                     0x5     //距离5m

#define LOCK                                0x1     //上锁
#define UNLOCK                              0x2     //解锁

#define MUSIC                               0x2     //音乐
#define TRIONES                             0x3     //北斗七星
#define HOLIDAY                             0x4     //节假日
#define DIY_IMG                             0x5     //自定义图案文字

/**************************Tail Signal Value*******************************/
#define TAIL_SEARCH_CAR                     0x1     //停车场寻车
#define TAIL_WELCOME                        0x2     //迎宾
#define TAIL_FAREWELL                       0x3     //欢送
#define TAIL_DOOR_OPEN                      0x4     //左侧门打开
#define TAIL_TURN_LEFT                      0x5     //左转
#define TAIL_TURN_RIGHT                     0x6     //右转
#define TAIL_U_TURN                         0x7     //掉头
#define TAIL_BACK                           0x8     //倒车
#define TAIL_EMERGENCY_BRAKE                0x9     //紧急制动
#define TAIL_AUTO_DRIVE                     0xa     //自动驾驶模式
#define TAIL_TEMP_STOP                      0xb     //临时停车
#define TAIL_COMITY                         0xc     //礼让行人
#define TAIL_TRIONES                        0xd     //北斗七星
#define TAIL_HOLIDAY                        0xe     //节假日提示
#define TAIL_DIY_IMG                        0xf     //自定义图案文字


/**************************Projection Signal Value*******************************/
#define PJT_SEARCH_CAR                      0x1     //寻车
#define PJT_WELCOME                         0x2     //迎宾
#define PJT_FAREWELL                        0x3     //欢送
#define PJT_TURN_LEFT                       0x4     //左转
#define PJT_TURN_RIGHT                      0x5     //右转
#define PJT_U_TURN                          0x6     //掉头
#define PJT_TEMP_STOP                       0x7     //临时停车
#define PJT_COMITY                          0x8     //礼让行人
#define PJT_CORNER_DANGER                   0x9     //转角来车、行人预警
#define PJT_BATTERY_STATUS                  0xa     //电量提示
#define PJT_CHARGE                          0xb     //充电提示
#define PJT_MUSIC_RHYTHM                    0xc     //音乐律动
#define PJT_TRIONES                         0xd     //北斗七星
#define PJT_HOLIDAY                         0xe     //节假日提示
#define PJT_DIY_IMG                         0xf     //自定义图案文字


/**************************Reading Signal Value*******************************/
#define RDG_FRONT_ON                        0x1     //前灯亮
#define RDG_LEFT_ON                         0x2     //左灯亮
#define RDG_RIGHT_ON                        0x3     //右灯亮
#define RDG_ALL_ON                          0x4     //三灯全亮

#define RDG_FRONT_LED1                      0x1     //LED1 on
#define RDG_FRONT_LED2                      0x2     //LED2 on
#define RDG_FRONT_LED3                      0x3     //LED3 on
#define RDG_FRONT_ALL                       0x4     //LED ALL on
#define RDG_SKYLIGHT_ON                     0x5     //天窗开
#define RDG_SKYLIGHT_OFF                    0x6     //天窗关

#define RDG_BEHIND_LED1                     0x1     //LED1 on
#define RDG_BEHIND_LED2                     0x2     //LED2 on
#define RDG_BEHIND_LED3                     0x3     //LED3 on
#define RDG_BEHIND_LED4                     0x4     //LE4 on
#define RDG_BEHIND_LED5                     0x5     //LED5 on
#define RDG_BEHIND_ALL                      0x6     //LED ALL on
#define RDG_AMUSE_MODE1                     0x7     //贪吃蛇模式  
#define RDG_AMUSE_MODE2                     0x8     //海浪模式

#define GESTURE_DETECT                      0x1     //手势识别模式
#define HAND_TRACK                          0x2     //手部跟踪模式

#define RDG_CHILD_DETECT                    0x1     //儿童遗留检测

/**************************Grillage Signal Value*******************************/
#define GRE_SEARCH_CAR                      0x1     //寻车
#define GRE_WELCOME                         0x2     //迎宾
#define GRE_FAREWELL                        0x3     //欢送
#define GRE_TEMP_STOP                       0x4     //临时停车
#define GRE_COMITY                          0x5     //礼让行人
#define GRE_CHARGE                          0x6     //充电提示
#define GRE_MUSIC_RHYTHM                    0x7     //音乐律动
#define GRE_TRIONES                         0x8     //北斗七星  
#define GRE_LIFE_DETECT                     0x9     //宠物、儿童遗留提示

/**************************MusicLoudness Level*******************************/
#define INVALID                             0x1F
#define LEVEL_1                             0x0
#define LEVEL_2                             0x1
#define LEVEL_3                             0x2
#define LEVEL_4                             0x3
#define LEVEL_5                             0x4
#define LEVEL_6                             0x5
#define LEVEL_7                             0x6
#define LEVEL_8                             0x7
#define LEVEL_9                             0x8
#define LEVEL_10                            0x9
#define LEVEL_11                            0xa
#define LEVEL_12                            0xb
#define LEVEL_13                            0xc
#define LEVEL_14                            0xd
#define LEVEL_15                            0xe
#define LEVEL_16                            0xf



/*RX CAN*/
union protocol_64bit_GATE
{
    uint8_t data_buffer[8];
    struct
    {
        uint64_t RHTurnlightSts                  : 1;
        uint64_t LHTurnlightSts                  : 1;
        uint64_t DriverDoorSts                   : 1;
        uint64_t PsngrDoorSts                    : 1;
        uint64_t HoodSts                         : 1;
        uint64_t ParkLightSts                    : 1;
        uint64_t RHRDoorSts                      : 1;
        uint64_t LHRDoorSts                      : 1;
        uint64_t BCM_4_KeySts                    : 2;
        uint64_t BCM_4_DRLSts                    : 1;
        uint64_t RVSMode                         : 1;
        uint64_t FollowMeTimeSts                 : 4;
        uint64_t BCM_4_ReverseGearSts            : 1;
        uint64_t BCM_20_BrkLampSts               : 1;
        uint64_t BCM_20_Welcomelightcmd          : 2;
        uint64_t RvsLampSts                      : 1;
        uint64_t OrderInformation                : 4;
        uint64_t SteeringAngle                   : 16;
        uint64_t TBOX_SearchVehicleReq           : 1;
        uint64_t BCM_4_DriverDoorLockSts         : 1;
        uint64_t BLRequestController             : 1;
        uint64_t SmartSystemWarning3_1           : 1;
        uint64_t IBS_SOC                         : 8;
    }ptrGATE;
};

union protocol_64bit_HTCU
{
    uint8_t data_buffer[8];
    struct
    {
        uint64_t AVM_APA_1_HzrdLiReq             : 1;
        uint64_t APA_Active                      : 1;
        uint64_t MEB_SpeakReq                    : 1;
        uint64_t MEB_DistanceToCollision         : 12;
        uint64_t MEB_LedReq                      : 1;
        uint64_t EngineSpeed                     : 11;
        uint64_t IDCU_1_ObjN1Dst                 : 9;
        uint64_t IDCU_1_ObjN1_Type               : 3;
        uint64_t ESP_APA_Target_Gear_Request     : 3;
        uint64_t ABS_ESP_1_HDCCtrlSts            : 2;
        uint64_t HDCCtrlSts                      : 2;
        uint64_t VehicleSpeedVSOSig              : 13;
        uint64_t STAT_LeverModeDisp              : 3;
    }ptrHTCU;
};

union protocol_64bit_SENSOR
{
    uint8_t data_buffer[8];
    struct 
    {
        uint8_t Front_Gesture_LED                : 3;
        uint8_t Behind_Gesture_LED               : 4;
        uint8_t Mode_Control                     : 2;
        uint8_t HandTracK_LED                    : 3;
        uint8_t Child_Detection                  : 1;
    }ptrSENSOR;
};

union protocol_64bit_MUSICLOUD
{
    uint8_t data_buffer[8];
    struct 
    {
        uint64_t MusicLoudness_120HZ             : 5;
        uint64_t ADBenable                       : 2;
        uint64_t MusicLoudness_250HZ             : 5;
        uint64_t LiShowMod                       : 3;
        uint64_t MusicLoudness_500HZ             : 5;
        uint64_t MusicLoudness_1000HZ            : 5;
        uint64_t MusicShowCMD                    : 1;
        uint64_t MusicLoudness_1500HZ            : 5;
        uint64_t MusicLoudness_2000HZ            : 5;
        uint64_t MusicLoudness_6000HZ            : 5;
    }ptrMUSIC;
};

/*TX CAN */
union protocol_SendMsg
{
    uint8_t data[8];
    struct
    {
        uint8_t TAIL_Sts                        : 5;
        uint8_t Reserved                        : 3;
        uint8_t CAR_Sts                         : 2;
        uint8_t DriverDoorSts                   : 1;
        uint8_t PsngrDoorSts                    : 1;
        uint8_t RHRDoorSts                      : 1;
        uint8_t LHRDoorSts                      : 1;
    }ptrDOMAIN_BEHIND; 
};



#endif /* USER_DEFINE_H_ */
